Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@es-git/object-mixin

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-git/object-mixin

This is part of the [ES-Git](https://github.com/es-git/es-git) project.

  • 0.1.2
  • npm
  • Socket score

Version published
Weekly downloads
24
decreased by-17.24%
Maintainers
1
Weekly downloads
 
Created
Source

objects-mixin

This is part of the ES-Git project.

Install

npm install --save @es-git/objects-mixin

Usage

Mix this in with an IRawRepo.

This mixin can encode objects as binary and calculate their hash before saving to an IRawRepo. Using the hash it can load the binary from the IRawRepo and then decode the object.

import objectsMixin from '@es-git/objects-mixin';
import MemoryRepo from '@es-git/memory-repo';

const Repo = mix(MemoryRepo)
            .with(objectsMixin);

const repo = new Repo();
const hash = await repo.saveObject(gitObject);
const gitObject = await repo.loadObject(hash);

Interfaces

IObjectRepo

interface IObjectRepo {
  saveObject(object : GitObject) : Promise<Hash>
  loadObject(hash : Hash) : Promise<GitObject | undefined>
}

GitObject

type GitObject = BlobObject | TreeObject | CommitObject | TagObject;
type Body = Uint8Array | TreeBody | CommitBody | TagBody;

type Hash = string;

type BlobObject = {
  readonly type : Type.blob
  readonly body : Uint8Array
}

type TreeObject = {
  readonly type : Type.tree
  readonly body : TreeBody
}

type TreeBody = {
  [key : string] : ModeHash
}

type ModeHash = {
  readonly mode : Mode
  readonly hash : string
}

type CommitObject = {
  readonly type : Type.commit
  readonly body : CommitBody
}

type CommitBody = {
  readonly tree : string
  readonly parents : string[]
  readonly author : Person
  readonly committer : Person
  readonly message : string
}

type Person = {
  readonly name : string
  readonly email : string
  readonly date : Date | SecondsWithOffset
}

type SecondsWithOffset = {
  readonly seconds : number
  readonly offset : number
}

type TagObject = {
  readonly type : Type.tag
  readonly body : TagBody
}

type TagBody = {
  readonly object : string
  readonly type : string
  readonly tag : string
  readonly tagger : Person
  readonly message : string
}

FAQs

Package last updated on 19 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc